// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;
using System.Linq;
using System.Text;
using Antlr4.Runtime.Misc;
using Templating.Grammar.Antlr;
using static Templating.Grammar.Antlr.TemplatingParser;

namespace SnapObjects.Data
{
    internal partial class DataTemplateConverter
        : TemplatingParserBaseVisitor<StringBuilder>
        , ITemplatingParserVisitor<StringBuilder>
    {
        public override StringBuilder VisitForeach([NotNull] ForeachContext context)
        {
            var foreachExpr = context.foreachExpr();

            this.Visit(foreachExpr.bodyExpr());

            return _builder;
        }

        public override StringBuilder VisitBodyExpr([NotNull] BodyExprContext context)
        {
            var expressions = context.children.ToArray();

            Array.ForEach(expressions, x => this.Visit(x));

            return _builder;
        }
    }
}
